﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Experimental.Playables.TextureMixerPlayable
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;
using UnityEngine.Playables;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine.Experimental.Playables
{
  /// <summary>
  ///   <para>An implementation of IPlayable that allows mixing two textures.</para>
  /// </summary>
  [NativeHeader("Runtime/Director/Core/HPlayable.h")]
  [StaticAccessor("TextureMixerPlayableBindings", StaticAccessorType.DoubleColon)]
  [RequiredByNativeCode]
  [NativeHeader("Runtime/Export/Director/TextureMixerPlayable.bindings.h")]
  [NativeHeader("Runtime/Graphics/Director/TextureMixerPlayable.h")]
  public struct TextureMixerPlayable : IPlayable, IEquatable<TextureMixerPlayable>
  {
    private PlayableHandle m_Handle;

    /// <summary>
    ///   <para>Creates a TextureMixerPlayable in the PlayableGraph.</para>
    /// </summary>
    /// <param name="graph">The PlayableGraph object that will own the TextureMixerPlayable.</param>
    /// <returns>
    ///   <para>A TextureMixerPlayable linked to the PlayableGraph.</para>
    /// </returns>
    public static TextureMixerPlayable Create(PlayableGraph graph)
    {
      return new TextureMixerPlayable(TextureMixerPlayable.CreateHandle(graph));
    }

    private static PlayableHandle CreateHandle(PlayableGraph graph)
    {
      PlayableHandle handle = PlayableHandle.Null;
      return !TextureMixerPlayable.CreateTextureMixerPlayableInternal(ref graph, ref handle) ? PlayableHandle.Null : handle;
    }

    internal TextureMixerPlayable(PlayableHandle handle)
    {
      this.m_Handle = !handle.IsValid() || handle.IsPlayableOfType<TextureMixerPlayable>() ? handle : throw new InvalidCastException("Can't set handle: the playable is not an TextureMixerPlayable.");
    }

    public PlayableHandle GetHandle() => this.m_Handle;

    public static implicit operator Playable(TextureMixerPlayable playable)
    {
      return new Playable(playable.GetHandle());
    }

    public static explicit operator TextureMixerPlayable(Playable playable)
    {
      return new TextureMixerPlayable(playable.GetHandle());
    }

    public bool Equals(TextureMixerPlayable other) => this.GetHandle() == other.GetHandle();

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool CreateTextureMixerPlayableInternal(
      ref PlayableGraph graph,
      ref PlayableHandle handle);
  }
}
